﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;
using System.Web.UI.DataVisualization.Charting;
using CRM.BLL;
using CRM.Entity;
using DP.Web.UI;

using System.Web.Script.Serialization;
using System.Xml;
using DP.Common;

namespace CRM.Web.Test
{
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DateTime beginDateTime = DateTime.Now;
            for (int i = 0; i < 100; i++)
            {
                UserLoginInfo.WriteWorkOrderLog("TESTSTST", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            }
            UserLoginInfo.WriteWorkOrderLog("TESTSTST", String.Format("Begin:{0}--End:{1}--Diff:{2}--", beginDateTime.ToString("HH:mm:ss.fff"), DateTime.Now.ToString("HH:mm:ss.fff"), DateTime.Now.Subtract(beginDateTime)));


            string xml = "<results><result inum=\"811029000092988\"><field name=\"startedat\">2011-12-12T12:11:19.152</field><field name=\"duration\">1</field><field name=\"partyagentnames\">0018</field><field name=\"partynames\">6025 (digital), 013764187009 (liantong)</field><field name=\"vdn\">5101 (nongzhuangzixun)</field><field name=\"callid\">00001017761323663156</field></result><result inum=\"811029000092989\"><field name=\"startedat\">2011-12-12T12:11:20.415</field><field name=\"duration\">31</field><field name=\"partyagentnames\">0018</field><field name=\"partynames\">6025 (digital), 4025 (vp), 013764187009 (liantong)</field><field name=\"callid\">00001017761323663156</field></result></results>";


            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(xml);
            List<RecordResult> list = new List<RecordResult>();


            XmlNodeList xmlSubNodeList;
            XmlNodeList xmlNodeList = xmlDocument.GetElementsByTagName("result");
            foreach (XmlNode xmlNode in xmlNodeList)
            {
                RecordResult entity = new RecordResult();
                entity.inum = xmlNode.Attributes["inum"].Value;
                xmlSubNodeList = xmlNode.ChildNodes;
                foreach (XmlNode xmlSubNode in xmlSubNodeList)
                {
                    switch (xmlSubNode.Attributes["name"].Value)
                    {
                        case "startedat":
                            {
                                entity.startedat = DateTimeHelper.ToDateTime(xmlSubNode.InnerText.Replace("T", " "));
                            }
                            break;
                        case "duration":
                            {
                                entity.duration = StringHelper.ToInt(xmlSubNode.InnerText);
                            }
                            break;
                        case "partynames":
                            {
                                entity.partynames = xmlSubNode.InnerText;
                            }
                            break;
                        case "callid":
                            {
                                entity.callid = xmlSubNode.InnerText;
                            }
                            break;
                        case "partyagentnames":
                            {
                                entity.partyagentnames = xmlSubNode.InnerText;
                            }
                            break;
                        case "vdn":
                            {
                                entity.vdn = xmlSubNode.InnerText;
                            }
                            break;

                    }
                }
                list.Add(entity);
            }


            
            double d = 1.1111;
            //long ss = (long)(d + 0.5);
            ////T_RECORD_BLL recordBll = new T_RECORD_BLL();
            ////recordBll.GetRemoteInfo("1012201283667055");
            //string jsonText = "[{\"ContactId\":\"7544807085\",\"StyleBrand\":\"安美弛\",\"StyleId\":\"JB131644\",\"StyleName\":\"安美弛太阳能可爱晴天娃娃 带吸盘\",\"StylePrice\":\"25.0000\",\"StyleStar\":\"0\",\"StylePicUrl\":\"/GOODS/SUPERMAP/N40800/JB131644M80011.JPG\"}]";
            //JavaScriptSerializer s = new JavaScriptSerializer();

            //List<TestEntity> list = s.Deserialize<List<TestEntity>>(jsonText);

            //if (list == null)
            //{

            //}
            //else
            //{

            //}

            //return;
            //if (PageHelper.GetQueryString(this.Page).Count == 0)
            //{
                
            //}




            //// Populate series data
            //double[] yValues = { 65.62, 75.54, 60.45, 55.73, 70.42 };
            //string[] xValues = { "France", "Canada", "UK", "USA", "Italy" };
            //Chart1.Series["Default"].Points.DataBindXY(xValues, yValues);
            //Chart1.ImageLocation = "~/TempFilePath/TempImages/";
            //Chart1.ImageStorageMode = ImageStorageMode.UseImageLocation;


            //if (this.ChartTypeList.SelectedItem.ToString() == "Pie")
            //    Chart1.Series["Default"].ChartType = SeriesChartType.Pie;

            //else
            //    Chart1.Series["Default"].ChartType = SeriesChartType.Doughnut;

            //if (this.ShowLegend.Checked)
            //    Chart1.Series["Default"]["PieLabelStyle"] = "Disabled";

            //else
            //    Chart1.Series["Default"]["PieLabelStyle"] = "Inside";

            //// Set chart type and title
            //Chart1.Series["Default"].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), this.ChartTypeList.SelectedItem.ToString(), true);
            //Chart1.Titles[0].Text = ChartTypeList.SelectedItem.ToString() + " Chart";

            //// Set labels style
            //Chart1.Series["Default"]["PieLabelStyle"] = this.LabelStyleList.SelectedItem.ToString();

            //// Set Doughnut hole size
            //Chart1.Series["Default"]["DoughnutRadius"] = this.HoleSizeList.SelectedItem.ToString();

            //// Disable Doughnut hole size control for Pie chart
            //this.HoleSizeList.Enabled = (this.ChartTypeList.SelectedItem.ToString() != "Pie");

            //// Explode selected country
            //foreach (DataPoint point in Chart1.Series["Default"].Points)
            //{
            //    point["Exploded"] = "false";
            //    if (point.AxisLabel == this.ExplodedPointList.SelectedItem.ToString())
            //    {
            //        point["Exploded"] = "true";
            //    }
            //}

            //// Enable 3D
            //Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = CheckboxShow3D.Checked;

            //Chart1.Series[0]["PieDrawingStyle"] = this.Dropdownlist1.SelectedItem.ToString();

            //// Pie drawing style
            //if (this.CheckboxShow3D.Checked)
            //    this.Dropdownlist1.Enabled = false;

            //else
            //    this.Dropdownlist1.Enabled = true;

            //if (this.ShowLegend.Checked)
            //    this.Chart1.Legends[0].Enabled = true;
            //else
            //    this.Chart1.Legends[0].Enabled = false;

        }





        protected void btnOK_Click(object sender, EventArgs e)
        {
            //Assembly a;

            //string s = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            ////让这个对象加载某个外部dll程序集信息.
            //a = Assembly.LoadFile(s + @"\Bin\Lovol.PlugIn.dll");

            ////定义一个"类型信息"的对象.
            //Type t = a.GetType("Lovol.PlugIn.Test", false, true);

            //MemberInfo[] info = t.GetMembers();

            //MethodInfo method = t.GetMethod("Show", new Type[] { Type.GetType("System.Int32"), Type.GetType("System.String") });

            //Object obj = a.CreateInstance("Lovol.PlugIn.Test");//必须使用名称空间+类名称

            //method.Invoke(obj, new object[] { 1, "A" }); //实例方法的调用


        }

        protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
        {

        }

    }

    public class TestObject
    {
        string data { get; set; }
    }

    public class TestEntity
    {
        public string ContactId { get; set; }
        public string StyleBrand { get; set; }
        public string StyleId { get; set; }
        public string StyleName { get; set; }
        public string StylePrice { get; set; }
        public string StyleStar { get; set; }
        public string StylePicUrl { get; set; }

    }


    public class RecordResult
    {
        public string inum { get; set; }
        public DateTime? startedat { get; set; }
        public int? duration { get; set; }
        public string partyagentnames { get; set; }
        public string partynames { get; set; }
        public string vdn { get; set; }
        public string callid { get; set; }
    }
}
